export default {
  namespaced: true,
  state: () => {
    return {
      list: [
        // {
        //   id: 1,
        //   address:"gjkhgjkghkjhn",
        //   name: "张三分",
        //   tel: "15846855512",
        //   addressDetail: "大西洋国际",
        //   areaCode: "320583",
        //   postalCode: "400000",
        //   isDefault: true,
        // },
      ],
    };
  },
 
  mutations: {
    addAddressmut(state, { obj, idx }) {
      if (obj.isDefault) {
        if (state.list.length) {
          state.list.forEach((item) => {
            item.isDefault = false;
          });
        }
      }
      if (idx == -1) {
        state.list.push(obj);
      } else {
        state.list[idx] = obj;
      }
    },
    delAddressmut(state,{content,idx}){
      state.list.forEach((item) => {
        if(item.id==content.id){
         state.list.splice(idx,1)
        }
      })
    }
  },
};
